#include "../../source/client/rpc_client.hpp"
#include "../../source/common/log.hpp"
#include <thread>

void callBack(const std::string &topic_name, const std::string &msg)
{
    LOG(JsonMuduoRPC::INFO, "%s 主题收到推送过来的消息 %s", topic_name.c_str(), msg.c_str());
}

int main()
{
    JsonMuduoRPC::client::TopicClient::ptr client =
        std::make_shared<JsonMuduoRPC::client::TopicClient>("127.0.0.1", 8080);

    client->create("music");
    bool ret = client->subscribe("music", callBack);
    if (ret == false)
    {
        LOG(JsonMuduoRPC::ERROR, "主题订阅失败");
        return 1;
    }

    std::this_thread::sleep_for(std::chrono::seconds(100));

    client->shutdown();

    return 0;
}